package hotLeetcode;

public class H35Leetcode {
    public int searchInsert(int[] nums, int target) {

        int left = 0;
        int right = nums.length - 1;















        while (left <= right) {
            int m = (left + right) / 2;
            if (nums[m] > target) {

                right--;
            } else if (nums[m] < target) {
                left++;

            } else {
                return (left + right) / 2;
            }


        }



        return left;
    }

    public static void main(String[] args) {
        int[] nums = {1, 3, 5, 6};
        H35Leetcode h35Leetcode = new H35Leetcode();
        h35Leetcode.searchInsert(nums, 7);
    }
}
